package com.miplus.ccrm.report.controller;

import com.miplus.ccrm.common.CmdResVo;
import com.miplus.ccrm.common.PageData;
import com.miplus.ccrm.common.R;
import com.miplus.ccrm.report.controller.vo.cases.RepaymentDetailsPageReqVo;
import com.miplus.ccrm.report.controller.vo.cases.RepaymentDetailsPageResVo;
import com.miplus.ccrm.report.security.JCommonData;
import com.miplus.ccrm.report.service.cases.FiCasesRepaymentDetailsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotNull;

/**
 * 3-4 案件报表
 */
@Slf4j
@CrossOrigin(origins = "*", maxAge = 3600)
@RestController
@RequestMapping("/case")
public class FiCaseController {

    @Resource
    private JCommonData jCommonData;
    @Resource
    private FiCasesRepaymentDetailsService repaymentDetailsService;

    /**
     * 取委案明细LIST
     * @param reqVo
     * @return
     */
    @PostMapping("/repaymentDetailsPage")
    public R<PageData<RepaymentDetailsPageResVo>>repaymentDetailsPage(@RequestBody @Validated RepaymentDetailsPageReqVo reqVo){
        return R.SuccessPage(repaymentDetailsService.page(reqVo));
    }

    /**
     * 委案明细导出
     * @return
     */
    @PostMapping("/expRecoveryTotal")
    public R<CmdResVo>expRepaymentDetails(@RequestBody @Validated RepaymentDetailsPageReqVo reqVo, HttpServletResponse response){
        String usrid= jCommonData.getCurrUsrID();
        return R.Success(repaymentDetailsService.expRepaymentDetails(usrid,reqVo,response));
    }

}
